<?php

namespace app\index\controller;

use app\index\model\ExplainStudent as ExplainStudentModel;
use app\index\model\ExplainTeacher as ExplainTeacherModel;
use app\index\model\Infomation as InfomationModel;
use think\Controller;
use think\Request;

class Info extends BaseController
{
    /**
     * 学生端说明
     */
    public function student()
    {
        $info = ExplainStudentModel::getAll();
        $this->successes(compact('info'));
    }

    /**
     * 学生端说明
     */
    public function teacher()
    {
        $info = ExplainTeacherModel::getAll();
        $this->successes(compact('info'));
    }

    /**
     * 咨询活动列表
     */
    public function lists()
    {
        $size = $this->request->get('size');
        $info = InfomationModel::lists($size);
        $info->total() ? $this->successes([
            'items' => $info->items(),
            'total' => $info->total()
        ]) : $this->errorMsg('暂无数据');
    }

    /**
     * 咨询活动详情
     */
    public function detail()
    {
        $infoId = $this->notEmpty('info_id');
        $info = InfomationModel::find($infoId);
        $this->successes(compact('info'));
    }

    /**
     * 客服热线 & 地址
     */
    public function basic()
    {
        $serviceMobile = getSettingValue('service_mobile');
        $mobileUse = getSettingValue('mobile_use');
        $address = getSettingValue('address');
        $addressEn = getSettingValue('address_en');
        $email = getSettingValue('email');
        $emailUse = getSettingValue('email_use');
        $record = getSettingValue('record');
        $recordEn = getSettingValue('record_en');
        $recordUse = getSettingValue('record_use');
        $xina = getSettingValue('xina');
        $this->successes([
            'service_mobile' => $serviceMobile,
            'mobile_use' => $mobileUse,
            'address' => $address,
            'address_en' => $addressEn,
            'email' => $email,
            'email_use' => $emailUse,
            'record' => $record,
            'record_en' => $recordEn,
            'record_use' => $recordUse,
            'xina' => $xina
        ]);
    }
}
